function Notification(content,time)
{
this.content=content;
this.time=time;
}
function pingServer()
{
if(dummy_flag==0)
dummy_flag=1;
else
dummy_flag=0;
var page="ping.php";
var args="user="+nativeGetUserName()+"&flag="+dummy_flag+"&start="+start+"&start_time="+start_time;
var xmlhttp=loadAjax();
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4)
    {
var obj = eval ("(" + xmlhttp.responseText  + ")");
if(obj.messages.length>1)
{
start_time=obj.messages[obj.messages.length-2].time;
for(var i=0;i<=obj.messages.length-2;i++)
{
notifications[not_index++]=new Notification(obj.messages[i].content,obj.messages[i].time);
}
if(init_disp==0)
{
document.getElementById('content2').innerHTML=notifications[0].content;
init_disp=1;
}
refreshContentBars();
if(nativeGetWindowstate()==0)
nativeMaximizeApp();
}
else
{
if(start==1)
{
start_time=obj.messages[obj.messages.length-1].time;
document.getElementById('content2').innerHTML="no notifications to display";
}
}
if(start==1)
{
start=0;
}
setTimeout("pingServer()",30000);
    }
  }
if(args!="" || args!=null) args+="&rand="+Math.random();
else args="rand="+Math.random();
xmlhttp.open("GET",page+"?"+args,true);
xmlhttp.send();
}
var dummy_flag=0;
var start=1;
var init_disp=0;
var start_time="";
var notifications=new Array();
var not_index=0;


function refreshContentBars()
{
if(curr_index<not_index-1)
document.getElementById('content3').innerHTML="<a href=\"#\" onclick=\"javascript:next()\">&gt;</a>";
else
document.getElementById('content3').innerHTML="&gt;";

if(curr_index==0)
document.getElementById('content1').innerHTML="&lt;";
else
document.getElementById('content1').innerHTML="<a href=\"#\" onclick=\"javascript:back()\">&lt;</a>";
}
function next()
{
document.getElementById('content2').innerHTML=notifications[++curr_index].content;
refreshContentBars();
}
function back()
{
document.getElementById('content2').innerHTML=notifications[--curr_index].content;
refreshContentBars();
}
var curr_index=0;